package com.wc.codeforces.数学.推导.Fun;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/7/28 10:15
 * @description https://codeforces.com/contest/1996/problem/D
 */
public class Main {
    /**
     * 思路:
     * ab + ac + bc <= n => ab <= n, b <= n / a, 当 a = 1, b <= n, b => 1 ~ n
     * a + b + c <= x, b <= x  => b <= min(n/a, x)
     * ab + c(a + b) <= n => c <= (n - ab) / (a + b)
     * a + b + c <= x, c <= x - (a + b) => c <= min((n - ab) / (a + b), x - (a + b))
     * 推导完毕
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int n, x;

    public static void main(String[] args) {
        int T = sc.nextInt();

        while (T-- > 0) {
            n = sc.nextInt();
            x = sc.nextInt();
            long res = 0;
            for (int a = 1; a <= n; a++) {
                for (int b = 1; b <= Math.min(n / a, x); b++) {
                    int c = Math.min((n - a * b) / (a + b), x - (a + b));
                    if (c > 0) res += c;
                }
            }
            out.println(res);
        }

        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
